/**
 * Created by zhou on 2016/7/26.
 */


$(function(){
    //var col=[
    //    //{title:"<input type='checkBox' />",name:"TASKNAME",width:"5%",align:"center",format:function(data){return "<input class='input_select' value='"+data["ID"]+"' type='checkBox' />"}},
    //    {title:tableOpt.getCheckBox(null),name:"ID",width:"",align:"center",format:function(json){return tableOpt.getCheckBox(json.ID)}},
    //    {title:"任务名称",name:"TASKNAME",width:"10%",align:"center"},
    //    {title:"管道名称",name:"LINENAME",width:"15%",align:"center"},
    //    {title:"发球点",name:"FROMPIG",width:"10%",align:"center"},
    //    {title:"收球点",name:"TOPIG",width:"10%",align:"center"},
    //    {title:"计划清管时间",name:"PLANPAGDATETIME",width:"15%",align:"center"},
    //    {title:"创建人",name:"CREATEUSER",width:"10%",align:"center"},
    //    {title:"状态",name:"STAUS",width:"10%",align:"center",format:function(json){ return tableOpt.getState(json.STAUS)}},
    //    {title:"编辑",name:"ID",width:"5%",align:"center",format:function(json){return tableOpt.getAdd(json.ID)}},
    //    {title:"发布",name:"ID",width:"5%",align:"center",format:function(json){return tableOpt.getPublish(json.ID)}},
    //    {title:"附件",name:"ID",width:"5%",align:"center",format:function(json){return tableOpt.getDownload(json.ID)}}
    //];
    //
    //
    //
    //    new page(".container-fluid:eq(1)",col,undefined,undefined,function(){
    //        $(".tabBox table td").css("border","0px ");
    //        $(".tabBox table th").css("border","0px ")
    //    });



    init2();
})



//初始化页面信息
init2=function() {

    $(".btn.copyBtn").click(function () {
        if ($(".table-ck span[name=checkSingle] .active").length == 1) {

            var data = $(".table-ck .active").parents("tr").data("trData");
            if(data.STAUS == 2)
            {
                $(this).MSG({content:'已发布的信息不能复制!'});
                $(".tabBox").refresh();
                return;
            }
            $("#copycccc").modal("show");
            $(".modal-backdrop.fade.in").unbind("click");
            $(".modal-backdrop.fade.in").die();
            $("#copycccc").initData(data);
        } else {
            $(this).MSG({content:'请选择一条任务记录再进行复制操作!'});
        }

    })


    $("#copycccc .save").click(function () {

        var taskName = $.trim($("#copyTaskName").val());
        var planTime = $("#copyPlanTime").val();
        var pigType = $("#copyPigType").children().html();
        //var fromPig = $("#copyFromPig").val();
        //var toPig = $("#copyToPig").val();
        //var remark = $("#copyRemark").val();
        //var pagePath = $("#pagePath").val();
        //var url = pagePath + "/pig/cleanPipeLineManager/copySave.json";
        if("" == taskName || null == taskName || undefined == taskName){
            $(this).MSG({content:'请输入任务名称'});
            $(".zy-msg-mask-box").css("z-index","99998");
            $(".zy-msg-outer").css("z-index","99999");
            return ;
        }

        if("" == pigType || null == pigType || undefined == pigType){
            $(this).MSG({content:'请输入清管工具'});
            $(".zy-msg-mask-box").css("z-index","99998");
            $(".zy-msg-outer").css("z-index","99999");
            return ;
        }
        if("" == planTime || null == planTime || undefined == planTime){
            $(this).MSG({content:'请选择计划清管时间'});
            $(".zy-msg-mask-box").css("z-index","99998");

            $(".zy-msg-outer").css("z-index","99999");
            return;
        }

        $("#copycccc").submit(function (data) {
            var msgCode = data.msgCode;
            if("1" == msgCode){
                $(this).MSG({content:'任务名称已经被使用，请重新输入'});
                $(".zy-msg-mask-box").css("z-index","99998");
                $(".zy-msg-outer").css("z-index","99999");

                return;
            }else if("ok" == msgCode){
                $(this).MSG({content:'保存成功'});
                $(".zy-msg-mask-box").css("z-index","99998");
                $(".zy-msg-outer").css("z-index","99999");
                $(".tabBox").refresh();
            }

        });
    })


}
//
//
//    $(".delAll").click(function(){
//        if($(".input_select:checked").length > 0)
//        {
//
//            var data="";
//            $(".input_select:checked").each(function(){
//
//                data+=$(this).val()+",";
//            })
//            resultAjax(path+"/pig/cleanPipeLineManager/deleteFun.json","idStr="+data,function(data){
//                if(data.result != undefined)
//                {
//                    data=data.result;
//                }
//                alert("成功删除["+data.delCount+"]条任务");
//                $(".tabBox").refresh();
//
//            },"json");
//        }else
//        {
//            alert("请选择需要删除的任务记录！");
//        }
//    })
//
//    $(".sendAll").click(function(){
//        if($(".input_select:checked").length > 0)
//        {
//
//            var data="";
//            $(".input_select:checked").each(function(){
//
//                data+=$(this).val()+",";
//            })
//            resultAjax(path+"/pig/cleanPipeLineManager/publishFun.json","idStr="+data,function(data){
//                if(data.result != undefined)
//                {
//                    data=data.result;
//                }
//                alert("成功发布["+data+"]条任务");
//                $(".tabBox").refresh();
//
//            },"json");
//        }else
//        {
//            alert("请选择需要发布的任务记录！");
//        }
//    })
//
//
//}




